package cn.tedu.ssm.mapper;

import cn.tedu.ssm.pojo.Good;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface GoodMapper {
    @Select("SELECT id, name, price from hbeu_goods limit #{offset},#{limit}")
    public List<Good> findAll(@Param("offset") int offset, @Param("limit") int limit);


    @Select("SELECT COUNT(1) FROM `hbeu_goods`")
    public Long count();


    @Update("UPDATE `hbeu_goods` set name=#{name} , price=#{price} where id=#{id}")
    public Long update(@Param("id") Long id, @Param("name") String name, @Param("price")Float price);


    @Select("SELECT id, name, price from hbeu_goods where id=#{id}")
    public Good findById(@Param("id") Long id);



    @Insert("INSERT INTO `hbeu_goods`(`name`, `price`) VALUES(#{name}, #{price})")
    public Long insert(@Param("name") String name, @Param("price") Float price);


    @Delete("DELETE FROM hbeu_goods WHERE id=#{id};")
    public Long delete(@Param("id") Long id);


    @Select("SELECT count(1) FROM hbeu_goods WHERE id = #{id}")
    public Boolean existsId(@Param("id") Long id);
}